<?php

use Illuminate\Support\Str;

return [

    /*
    |--------------------------------------------------------------------------
    | Default Database Connection Name
    |--------------------------------------------------------------------------
    |
    | Here you may specify which of the database connections below you wish
    | to use as your default connection for all database work. Of course
    | you may use many connections at once using the Database library.
    |
    */

    'default' => env('DB_CONNECTION', 'mysql'),

    /*
    |--------------------------------------------------------------------------
    | Database Connections
    |--------------------------------------------------------------------------
    |
    | Here are each of the database connections setup for your application.
    | Of course, examples of configuring each database platform that is
    | supported by Laravel is shown below to make development simple.
    |
    |
    | All database work in Laravel is done through the PHP PDO facilities
    | so make sure you have the driver for your particular database of
    | choice installed on your machine before you begin development.
    |
    */

    'connections' => [
        //本地数据库配置
        'mysql' => [
            'read'        => [   //从库
                'host'     => env('DB_READ_HOST', '127.0.0.1'),
                'port'     => env('DB_READ_PORT', '3306'),
                'username' => env('DB_READ_USERNAME', 'root'),
                'password' => env('DB_READ_PASSWORD', ''),
            ],
            'write'       => [   //主库
                'host'     => env('DB_WRITE_HOST', '127.0.0.1'),
                'port'     => env('DB_WRITE_PORT', '3306'),
                'username' => env('DB_WRITE_USERNAME', 'root'),
                'password' => env('DB_WRITE_PASSWORD', ''),
            ],
            'sticky'      =>    false,   //主从 新增或编辑一条记录，当前请求下强制查询主库（避免主从延迟）
            'driver'      => 'mysql',
            'database'    => env('DB_ADMIN_DATABASE', 'my'),
            'unix_socket' => env('DB_SOCKET', ''),
            'charset'     => 'utf8mb4',
            'collation'   => 'utf8mb4_unicode_ci',
            'prefix'      => env('DB_PURCHASE_PREFIX', 'xin_'),
            'strict'      => false,
            'engine'      => null,
        ],

        //用户中心
        'userCenter' => [
            'read'        => [   //从库
                'host'     => env('DB_READ_HOST', '127.0.0.1'),
                'port'     => env('DB_READ_PORT', '3306'),
                'username' => env('DB_READ_USERNAME', 'root'),
                'password' => env('DB_READ_PASSWORD', ''),
            ],
            'write'       => [   //主库
                'host'     => env('DB_WRITE_HOST', '127.0.0.1'),
                'port'     => env('DB_WRITE_PORT', '3306'),
                'username' => env('DB_WRITE_USERNAME', 'root'),
                'password' => env('DB_WRITE_PASSWORD', ''),
            ],
            'sticky'      =>  false,   //主从 新增或编辑一条记录，当前请求下强制查询主库（避免主从延迟）
            'driver'      => 'mysql',
            'database'    => env('USER_DB_DATABASE', 'xinxiaosi_user_center'),
            'unix_socket' => env('USER_DB_SOCKET', ''),
            'charset'     => 'utf8mb4',
            'collation'   => 'utf8mb4_unicode_ci',
            'prefix'      => env('USER_DB_PREFIX', 'xin_'),
            'strict'      => false,
            'engine'      => null,
        ],

        'pgsql' => [
            'driver' => 'pgsql',
            'url' => env('DATABASE_URL'),
            'host' => env('DB_HOST', '127.0.0.1'),
            'port' => env('DB_PORT', '5432'),
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            'charset' => 'utf8',
            'prefix' => '',
            'prefix_indexes' => true,
            'schema' => 'public',
            'sslmode' => 'prefer',
        ],

        'sqlsrv' => [
            'driver' => 'sqlsrv',
            'url' => env('DATABASE_URL'),
            'host' => env('DB_HOST', 'localhost'),
            'port' => env('DB_PORT', '1433'),
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            'charset' => 'utf8',
            'prefix' => '',
            'prefix_indexes' => true,
        ],

    ],

    /*
    |--------------------------------------------------------------------------
    | Migration Repository Table
    |--------------------------------------------------------------------------
    |
    | This table keeps track of all the migrations that have already run for
    | your application. Using this information, we can determine which of
    | the migrations on disk haven't actually been run in the database.
    |
    */

    'migrations' => 'migrations',

    /*
    |--------------------------------------------------------------------------
    | Redis Databases
    |--------------------------------------------------------------------------
    |
    | Redis is an open source, fast, and advanced key-value store that also
    | provides a richer body of commands than a typical key-value system
    | such as APC or Memcached. Laravel makes it easy to dig right in.
    |
    */

    'redis' => [
//
        'client' => env('REDIS_CLIENT', 'phpredis'),

//        'options' => [
//            'cluster' => env('REDIS_CLUSTER', 'redis'),
//            'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'),
//        ],
        //默认
        'default' => [
            'host' => env('DEFAULT_REDIS_HOST', '127.0.0.1'),
            'password' => env('DEFAULT_REDIS_PASSWORD', ''),
            'port' => env('DEFAULT_REDIS_PORT', 6379),
            'database' => env('DEFAULT_REDIS_DB', 0),
        ],

    ],

];
